import React, { PureComponent } from 'react'
import { connect } from 'react-redux'
import { changeBannersAction, fetchNetWorkDataAction } from '../store/actionCreators'
// import axios from 'axios'

export class Category extends PureComponent {

  componentDidMount() {
    // axios.get('http://123.207.32.32:8000/home/multidata').then(res => {
    //   const bannerList = res.data.data.banner.list
    //   console.log(bannerList)
    //   this.props.changeBanners(bannerList)
    // })
    this.props.changeBanners()
  } 

  render() {
    const { banner } = this.props
    return (
      <div> category </div>
    )
  }
}

const mapStateToProps = (state) => ({
  banner: state.banner
})

const mapDispatchToProps = (dispatch) => ({
  changeBanners() {
    // 这里就是派发一个函数
    dispatch(fetchNetWorkDataAction())
  }
})

export default connect(mapStateToProps, mapDispatchToProps)(Category)